<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <input type="button" value="页面跳转" id="btn" />
    <script>
      // location 和页面地址相关的一个对象
      //可读可写属性 location.href 取值：取到地址栏中完整的url地址 赋值：让页面发生跳转
      //console.log(location.href);
      /* btn.onclick = function () {
        location.href = "http://www.baidu.com";
      }; */
      //协议
      console.log(location.protocol);

      //主机名和端口
      console.log(location.host);

      //主机名
      console.log(location.hostname);

      //端口号
      console.log(location.port);

      //路径
      console.log(location.pathname);

      //查询字符串
      console.log(location.search); //？号之后的内容

      //hash值
      console.log(location.hash); //#号之后的内容

      //cookie
      const x = document.cookie;
      console.log(x);
      let obj = {};
      document.write(obj);
      console.log(obj);
    </script>
  </body>
</html>
